package com.exposit.zbs.converters;

import com.exposit.zbs.model.GrantApplication;
import com.exposit.zbs.service.IGrantApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;


/**
 * @author Andrey
 */
@Component
public class StringToGrantApplicationConverter implements Converter<String, GrantApplication> {

	@Autowired
	IGrantApplicationService grantAppService;

	/**
	 * This method used to converting GrantApplicationId to Grant Application Model Entity
	 *
	 * @param source ID of Grant Application in String
	 * @return GrantApplication Model Entity
	 */
	@Override
	public GrantApplication convert(String source) {

		Long id = new Long(source);
		GrantApplication grantApp = grantAppService.getGrantById(id);
		return grantApp;
	}

}
